define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'dealer.user/index',
        add_url: 'dealer.user/add',
        edit_url: 'dealer.user/edit',
        delete_url: 'dealer.user/delete',
        export_url: 'dealer.user/export',
        modify_url: 'dealer.user/modify',
    };

    return {
        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    // {type: 'checkbox'},
                    // {field: 'id', title: '用户表'},
                    // {field: 'openid', title: 'openid'},
                    {field: 'nick_name', title: '昵称'},
                    // {field: 'phone', title: '手机号'},
                    // {field: 'avatar', title: '头像' ,templet: ea.table.lazyimg ,search:'false' ,templet: function(d){
                    {field: 'avatar', title: '头像' ,search:'false' ,templet: function(d){
                        return '<img src="' + d.avatar + '" style="width: 40px; height: auto;">';
                    }},
                    // {field: 'type', search: 'select', selectList: {"1":"供应商","2":"经销商","3":"业务员","4":"店铺","0":"普通用户"}, title: '用户类型'},
                    {field: 'type', search: 'select', title: '用户类型' ,search:false
                    ,templet: function(d){
                        if (d.type == 0) {
                            return '普通用户';
                        } else if (d.type == 1) {
                            return '供应商';
                        } else if (d.type == 2) {
                            return '经销商';
                        } else if (d.type == 3) {
                            return '业务员';
                        } else if (d.type == 4) {
                            return '店铺';
                        } else if (d.type == 5) {
                            return '普通用户';
                        }
                    }},
                    {field: 'status', title: '状态', templet: ea.table.switch},
                    // {field: 'identity_id', title: '身份ID'},
                    {field: 'binding_status', title: '绑定状态' ,selectList: {"1":"绑定","0":"未绑定"},},
                    {field: 'identity_name', title: '身份名称(账号)' ,search:'false' ,templet: function(d){
                        return d.identity.name;
                    }},
                    {field: 'identity_phone', title: '联系方式' ,search:'false' ,templet: function(d){
                        return d.identity.phone;
                    }},
                    {field: 'create_time', minWidth: 100, title: '创建时间', search: 'range'},
                    // {width: 250, title: '操作', templet: ea.table.tool},

                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
});